<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<body>
<script>
    const t = async_test('Makes sure that dynamically removed preloaded resource stop downloading');
    const link = document.createElement("link");
    link.as = "script";
    link.rel = "preload";
    link.href = "../resources/dummy.js";
    const href = link.href;
    document.body.appendChild(link);
    document.body.removeChild(link);
    window.addEventListener("load", t.step_func_done(function() {
        const entries = performance.getEntriesByName(href);
        assert_equals(entries.length, 1);
        // If fully downloaded, the transferSize would have been 281.
        assert_less_than(entries[0].transferSize, 281);
    }));
</script>
<script src="../resources/slow-script.pl?delay=200"></script>
</body>
